package com.sdp.right.control;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sdp.core.bizc.db.Query;
import com.sdp.core.bizc.vo.DataCenter;
import com.sdp.core.bizc.vo.Result;
import com.sdp.right.db.sys_oper_log.service.ISysOperLogService;
import com.sdp.right.entity.SysOperLog;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zsp
 * @since 2023-10-19
 */
@RestController
@RequestMapping("/SysOperLogController")
public class SysOperLogController {

	@Autowired
	private ISysOperLogService iSysOperLogService;
	
	@Autowired
	private Query query;
	
	@PostMapping(value = "/page")
	public Result<?> page(@RequestBody DataCenter dataCenter) {
		return Result.ok(query.page(iSysOperLogService, SysOperLog.class, dataCenter));
	}
	
	@Transactional(rollbackFor=Exception.class)
	public void save(SysOperLog sysOperLog) {
		iSysOperLogService.save(sysOperLog);
	}
	
	@GetMapping(value="batchDel")
	@Transactional(rollbackFor=Exception.class)
	public Result<?> batchDel(@RequestParam(name="keyIds",required=true) List<String> keyIds) {
		if(keyIds==null || keyIds.size()==0) {
			return Result.error("请先选择要删除的记录");
		}
		iSysOperLogService.removeByIds(keyIds);
		return Result.ok();
	}
}

